/*
 * @Author: 周鹏飞
 * @Date: 2021-06-18 17:27:39
 * @LastEditors: 周鹏飞
 * @LastEditTime: 2021-07-05 10:32:25
 * @Description: file content
 */
function getMatterList(){
  $.ajax({
    type: 'POST',
    url: httpUrl + 'basicInfo/manager/category/getFacilitiesData/social_resources',
    data: "",
    dataType: 'json',
    contentType: "application/json",
    headers: {
      Authorization: localStorage.getItem('token')
    },
    success: function (res) {
      console.log(res);
      if (res.code == 200) {
        $('.material').css({ color: '#fe7272' })
        vm.$message({
          message: '资源查询成功',
          type: 'success'
        });
        // ClearLushu('CarPolicelushu')
        // ClearLushu('csxx')
        if (res.rows != 0) {
          vm.polymerizationemphasisMatterList = [];
          for (let [key, val] of Object.entries(res.rows)) {
            // 位置
            let point = new BMap.Point(val.lng, val.lat)
            // 创建led图标
            var myIcon = new BMap.Icon("./images/jk/ziyuanJh.png", new BMap.Size(50, 50));
            vm.map.centerAndZoom(new BMap.Point(111.989235, 32.790482), 11);
            var marker = new BMap.Marker(point, { icon: myIcon });
            // map.addOverlay(marker);    
            // 覆盖物标识
            marker.init = 'matter'
            vm.map.addOverlay(marker)
            marker.setTop({ isTop: true })
            var content = `
            <div id="ledBox" style="padding:10px">
            <div style="width: 100px; padding: 10px 0; margin: 10px 0; background: red; border-radius: 0 25px 25px 0; color: #ffffff;">
              &nbsp&nbsp&nbsp&nbsp 资源信息
            </div>
            <div id="carNumber" style="padding: 3px 10px;">
              地点: ${val.name}
            </div>
           
            <div id="carPosition" style="padding: 3px 10px;">
              描述:  ${val.details}
            </div>
          </div>
            `
            addClickHandler(content, marker, 'matter', val.id,point) // 监控信息窗口
            // 标签创建
            var name = `
                <div class='ledName' style='width: auto; height: 22px; padding: 2px 5px; line-height: 22px; text-align: center;'>
                  ${val.name}
                </div>`
            var Distance = val.name.length * 8
            var opts = {
              position: point,    // 指定文本标注所在的地理位置
              offset: new BMap.Size(-Distance, 15)    //设置文本偏移量
            }
            let label = new BMap.Label(name, opts);  // 创建文本标注对象
            label.init = "matter"
            label.setStyle({
              color: "#000",       //文本颜色
              fontSize: "14px",
              lineHeight: "24px",
              fontFamily: "微软雅黑",
              border: "0",
              borderRadius: '4px'
            });
            // 车辆信息聚合
            vm.polymerizationemphasisMatterList.push(marker)
  
            //  鼠标移入显示标题
            vm.polymerizationemphasisMatterList[key].addEventListener("mouseover", function (e) {
              vm.map.addOverlay(label);
            });
            // 鼠标移出把标题移除
            vm.polymerizationemphasisMatterList[key].addEventListener("mouseout", function (e) {
              vm.map.removeOverlay(label);
            });
  
  
          }
          vm.polymerizationemphasisMatter = new BMapLib.MarkerClusterer(vm.map, {
            markers: vm.polymerizationemphasisMatterList,
            styles: [{
              url: './images/jk/ziyuanJh.png',
              size: new BMap.Size(36, 36),
              color: 'pink',
              textSize: 20,
              textColor: 'red'
            }]
          });
          // 设置最大缩放级别
          vm.polymerizationemphasisMatter.setMaxZoom(11);
          searchLed()
        }
      } else if (res.code == 500) {
        vm.$message({
          message: '查询失败请联系管理员',
          type: 'error'
        });
      }
    },
    error: function (err) {
      vm.$message({
        message: '查询失败请稍后再试,或与管理员联系',
        type: 'error'
      });
    }
  })
}
